package com.ruoyi.whole.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.whole.domain.DmsDealerVehicleInfo;
import com.ruoyi.whole.service.IDmsDealerVehicleInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 车辆库存信息
Controller
 * 
 * @author liuchuanfa
 * @date 2024-03-03
 */
@RestController
@RequestMapping("/whole/inventory")
public class DmsDealerVehicleInfoController extends BaseController
{
    @Autowired
    private IDmsDealerVehicleInfoService dmsDealerVehicleInfoService;

    /**
     * 查询车辆库存信息列表
     */
    @PreAuthorize("@ss.hasPermi('whole:inventory:list')")
    @GetMapping("/list")
    public TableDataInfo list(DmsDealerVehicleInfo dmsDealerVehicleInfo)
    {
        startPage();
        List<DmsDealerVehicleInfo> list = dmsDealerVehicleInfoService.selectDmsDealerVehicleInfoList(dmsDealerVehicleInfo);
        return getDataTable(list);
    }

    /**
     * 导出车辆库存信息列表
     */
    @PreAuthorize("@ss.hasPermi('whole:inventory:export')")
    @Log(title = "车辆库存信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmsDealerVehicleInfo dmsDealerVehicleInfo)
    {
        List<DmsDealerVehicleInfo> list = dmsDealerVehicleInfoService.selectDmsDealerVehicleInfoList(dmsDealerVehicleInfo);
        ExcelUtil<DmsDealerVehicleInfo> util = new ExcelUtil<DmsDealerVehicleInfo>(DmsDealerVehicleInfo.class);
        util.exportExcel(response, list, "车辆库存信息数据");
    }

    /**
     * 获取车辆库存信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('whole:inventory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dmsDealerVehicleInfoService.selectDmsDealerVehicleInfoById(id));
    }

    /**
     * 新增车辆库存信息
     */
    @PreAuthorize("@ss.hasPermi('whole:inventory:add')")
    @Log(title = "车辆库存信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsDealerVehicleInfo dmsDealerVehicleInfo)
    {
        return toAjax(dmsDealerVehicleInfoService.insertDmsDealerVehicleInfo(dmsDealerVehicleInfo));
    }

    /**
     * 修改车辆库存信息
     */
    @PreAuthorize("@ss.hasPermi('whole:inventory:edit')")
    @Log(title = "车辆库存信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsDealerVehicleInfo dmsDealerVehicleInfo)
    {
        return toAjax(dmsDealerVehicleInfoService.updateDmsDealerVehicleInfo(dmsDealerVehicleInfo));
    }

    /**
     * 删除车辆库存信息
     */
    @PreAuthorize("@ss.hasPermi('whole:inventory:remove')")
    @Log(title = "车辆库存信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dmsDealerVehicleInfoService.deleteDmsDealerVehicleInfoByIds(ids));
    }
}
